//
//  UIImageView+Extension.m
//  GiftTalk
//
//  Created by Wan on 16/3/24.
//  Copyright © 2016年 Wan. All rights reserved.
//

#import "UIImageView+Extension.h"
#import <UIImageView+WebCache.h>

@implementation UIImageView (Category)

/** 用于存放占位图片 */
static UIImage *placeImage;

/**
 *  设置 UIImageView 的图片
 *
 *  @param imgeUrl     网络图片 url 路径
 *  @param palceHolder 本地占位图片名称
 */
- (void)setImage:(NSString *)imgUrl placeHolder:(NSString *)palceHolder;
{
    placeImage = [[UIImage imageNamed:imgUrl] circleImage];
    
    [self sd_setImageWithURL:[NSURL URLWithString:imgUrl] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        // 有返回网络图片用网络图片，没有则用占位图
        self.image = image ? image : placeImage;
    }];
}

@end
